package com.shijun.bean;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by zhushijun on 2017/12/31.
 */

public class GroupModle extends BaseModle {
    private List<ImageModle> images;
    private int weight;
    private int interval;//image子布局左右间隔

    public GroupModle(int weight,int interval,int width, int height, int marginLeft, int marginTop, int marginRight, int marginBottom){
        this.weight = weight;
        this.interval = interval;
        setWidthAndHeight(width, height);
        setMargin(marginLeft, marginTop, marginRight, marginBottom);
        images = new ArrayList<>();
    }

    public void setWeight(int weight) {
        this.weight = weight;
    }

    public void setImageModle(ImageModle image) {
        images.add(image);
    }

    public void setImageModles(ImageModle image, int count) {
        for (int i = 0; i < count; i++) {
            if(i!=0){
                images.add(image.clone());
            }else{
                images.add(image);
            }
        }
    }

    public List<ImageModle> getImages() {
        return images;
    }

    public ImageModle getImage(int position) {
        return images.get(position);
    }

    public int getWeight() {
        return weight;
    }

    public int getInterval() {
        return interval;
    }

    public void setInterval(int interval) {
        this.interval = interval;
    }

    public GroupModle clone(){
        GroupModle newGroupModle = new GroupModle(getWeight(),getInterval(),getWidth(),getHeight(),getMarginLeft(),getMarginTop(),getMarginRight(),getMarginBottom());
        for(int i = 0;i<getImages().size();i++){
            newGroupModle.setImageModle(getImage(i).clone());
        }
        return newGroupModle;
    }

    @Override
    public String toString() {
        return "GroupModle{" +
                "width=" + width +
                ", height=" + height +
                ", marginTop=" + marginTop +
                ", marginBottom=" + marginBottom +
                ", images=" + images +
                ", weight=" + weight +
                ", marginLeft=" + marginLeft +
                ", interval=" + interval +
                ", marginRight=" + marginRight +
                '}';
    }
}
